package huisu.onClass.class02.exer02;

import java.util.Arrays;
import java.util.Scanner;

public class Main {
    private static int drawCount = 0;
    private static int minColor = Integer.MAX_VALUE;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int vets = sc.nextInt();
        int colors = sc.nextInt();
        int[][] matrix = new int[vets][vets];
        String line = "";
        int v1 = sc.nextInt();
        int v2 = sc.nextInt();
        while (!(v1 == 0 && v2 == 0)) {
            matrix[v1 - 1][v2 - 1] = 1;
            matrix[v2 - 1][v1 - 1] = 1;
            v1 = sc.nextInt();
            v2 = sc.nextInt();
        }
        int[] map = new int[vets];
        Arrays.fill(map, -1);
        dfs(0, vets, colors, map, matrix);
        if (drawCount == 0) {
            minColor = 0;
        }
        System.out.println(drawCount + " " + minColor);
    }

    public static void dfs(int curV, int vets, int colors, int[] map, int[][] mat) {
        if (curV == vets) {
            drawCount++;
            boolean[] colorMap = new boolean[colors];
            for (int i = 0; i < vets; i++) {
                if (map[i] != -1) {
                    colorMap[map[i] - 1] = true;
                }
            }
            int colorCount = 0;
            for (int i = 0; i < colorMap.length; i++) {
                if (colorMap[i]) {
                    colorCount++;
                }
            }
            minColor = Math.min(minColor, colorCount);
            return;
        }
        for (int color = 1; color <= colors; color++) {
            boolean canSelect = true;
            for (int j = 0; j < vets; j++) {
                if (mat[j][curV] == 1 && map[j] == color) {
                    canSelect = false;
                    break;
                }
            }
            if (canSelect) {
                int srcColor = map[curV];
                map[curV] = color;
                dfs(curV + 1, vets, colors, map, mat);
                map[curV] = srcColor;
            }
        }
    }

}
